Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to create factory methods for Deriver API #662

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

pablf
Copy link
Member

@pablf pablf commented Feb 20, 2024

When calling a macro with a generic type parameter from a method with another generic type parameter, the macro is evaluated with the generic type instead of waiting until a concrete type is used. This raises a compile error in Scala 2:

def factory[A](deriver: Deriver[TC])(implicit schema: Schema[A]): TC[A] =
  Derive.derive[TC](deriver)

In Scala 3 this can be avoided using inline.

Adding a typeclass Factory allows to implement a factory method without having to create a macro calling deriveImpl in Scala 2.

@pablf pablf requested a review from a team as a code owner February 20, 2024 11:52
@vigoo vigoo merged commit 00d999b into zio:main Feb 27, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants